package com.copsoftware.mantenimientos.acusado.delegate;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.beans.BeanUtils;

import com.copsoftware.mantenimientos.acusado.assemblers.AcusadoAssembler;
import com.copsoftware.mantenimientos.acusado.beans.Acusado;
import com.copsoftware.mantenimientos.acusado.service.AcusadoService;
import com.copsoftware.struts.forms.AcusadoForm;
import com.copsoftware.struts.forms.RegistrarAcusadoInvestigacionForm;


public class AcusadoDelegate {
	
	public void guardarAcusado(RegistrarAcusadoInvestigacionForm form) throws Exception
	{
		AcusadoService acusadoService = new AcusadoService();
		Acusado acusado = AcusadoAssembler.createAcusado(form);
		acusadoService.guardarAcusado(acusado);
		form.setCPersona(String.valueOf(acusado.getCPersona()));
	}
	
	public void buscarAcusado(RegistrarAcusadoInvestigacionForm form)
	{
		AcusadoService acusadoService = new AcusadoService();
		Acusado acusado = AcusadoAssembler.createAcusado(form);
		acusadoService.buscarAcusado(acusado);
		form.setCPersona(String.valueOf(acusado.getCPersona()));
		BeanUtils.copyProperties(acusado, form,new String []{"CInvestigacion", "CPersona", "CBanda"});
		
	}
	
	public void buscarAcusado(AcusadoForm form)
	{
		AcusadoService acusadoService = new AcusadoService();
		Acusado acusado = new Acusado();
		acusado.setCPersona(form.getCPersona());
		acusadoService.buscarAcusado(acusado);
		BeanUtils.copyProperties(acusado, form);
				
	}
	
	public Collection buscarDelitosAcusado(Integer cAcusado)
	{
		AcusadoService acusadoService = new AcusadoService();
		Collection acusados = new ArrayList();
		acusados = acusadoService.buscarDelitosAcusado(cAcusado);
		return acusados;		
	}
	
		
		

}
